/**
 * Copyright &copy; 2013-2016 山东易科德软件有限公司   All rights reserved.
 */
package cn.net.ecode.modules.cms.service;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.net.ecode.common.persistence.Page;
import cn.net.ecode.common.service.CrudService;
import cn.net.ecode.common.utils.DateUtils;
import cn.net.ecode.modules.cms.dao.VisitLogDao;
import cn.net.ecode.modules.cms.entity.VisitLog;

/**
 * 访问日志Service
 * @author ThinkGem
 * @version 2015-12-28
 */
@Service
@Transactional(readOnly = true)
public class VisitLogService extends CrudService<VisitLogDao, VisitLog> {

	/**
	 * 获取单条数据
	 * @param visitLog
	 * @return
	 */
	public VisitLog get(VisitLog visitLog) {
		return super.get(visitLog);
	}
	
	/**
	 * 查询列表数据
	 * @param visitLog
	 * @return
	 */
	public List<VisitLog> findList(VisitLog visitLog) {
		return super.findList(visitLog);
	}
	
	/**
	 * 查询分页数据
	 * @param page 分页对象
	 * @param visitLog
	 * @return
	 */
	public Page<VisitLog> findPage(Page<VisitLog> page, VisitLog visitLog) {
		// 为了方便进行按天查询，设置一天的开始和结束时间（如：开始为一天的0点0分，结束为一天的23点59分）
		visitLog.setBeginVisitTime(DateUtils.getOfDayFirst(visitLog.getBeginVisitTime()));
		visitLog.setEndVisitTime(DateUtils.getOfDayLast(visitLog.getEndVisitTime()));
		return super.findPage(page, visitLog);
	}
	
	/**
	 * 统计概况，详情见：VisitLogDao.totalCount
	 * @param visitLog
	 * @return
	 */
	public Map<String, Object> totalCount(VisitLog visitLog){
		// 为了方便进行按天查询，设置一天的开始和结束时间（如：开始为一天的0点0分，结束为一天的23点59分）
		visitLog.setBeginVisitTime(DateUtils.getOfDayFirst(visitLog.getBeginVisitTime()));
		visitLog.setEndVisitTime(DateUtils.getOfDayLast(visitLog.getEndVisitTime()));
		return dao.totalCount(visitLog);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param visitLog
	 */
	@Transactional(readOnly = false)
	public void save(VisitLog visitLog) {
		super.save(visitLog);
	}
	
	/**
	 * 删除数据
	 * @param visitLog
	 */
	@Transactional(readOnly = false)
	public void delete(VisitLog visitLog) {
		super.delete(visitLog);
	}
	
}